package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.mouslisten.AddTeXiaoMouslisten;
import org.come.until.CutButtonImage;

import com.tool.btn.SpecificBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.come.until.MessagrFlagUntil;

public class ShowImageJpanel extends JPanel {

	private SpecificBtn btnBuy;// 购买按钮
	private JLabel labBorder,// 背景框
			labImg;// 特效图片展示
	private String name,// 特效名字
			value;// 价值多少仙玉

	private AddTeXiaoMouslisten xiaoMouslisten;

	public ShowImageJpanel() {
			this.setPreferredSize(new Dimension(80, 80));
			this.setLayout(null);
			this.setBackground(UIUtils.Color_BACK);

			xiaoMouslisten = new AddTeXiaoMouslisten();
			// 特效图片展示
			labImg = new JLabel();
			labImg.setBounds(0, 0, 62, 62);
			labImg.addMouseListener(xiaoMouslisten);
			this.add(labImg);

			// 背景框
			labBorder = new JLabel();
			labBorder.setBounds(0, 0, 63, 63);
			labBorder.setIcon(CutButtonImage.getImage("inkImg/number/b8/jinxiubjAJ.png", -1, -1));
			this.add(labBorder);

		    this.labImg.addMouseListener(new MouseListener() {
			@Override
			public void mouseClicked(final MouseEvent e) {
			}

			@Override
			public void mousePressed(final MouseEvent e) {
			}

			@Override
			public void mouseReleased(final MouseEvent e) {
			}

			@Override
			public void mouseEntered(final MouseEvent e) {
				if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE1)) {
					MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
				}
			}

			@Override
			public void mouseExited(final MouseEvent e) {
				if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE12)) {
					MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
				}
			}
		    });
			// 购买按钮
			btnBuy = new SpecificBtn("inkImg/number/b8/btnbuy1.png", 1, "", 10);
			btnBuy.setBounds(0, 100, 65, 20);
			this.add(btnBuy);

	}

	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		g.setFont(UIUtils.TEXT_FONT);
		g.setColor(Color.white);
		if (name != null) {
			g.drawString(name, 0, 75);
		}
		g.setColor(Color.red);
		if (value != null) {
            g.drawString(value, 0, 95);
        }
	}

	/*
	 * 清空界面的方法
	 */
	public void clearWindow() {
		name = "";
		value = "";
		labImg.setIcon(null);
		btnBuy.setBtn(0);
		btnBuy.setIcon(null);
		btnBuy.setText("");
		labBorder.setIcon(null);
		xiaoMouslisten.setEshop(null);
		btnBuy.setEshop(null);
	}

	public SpecificBtn getBtnBuy() {
		return btnBuy;
	}

	public void setBtnBuy(SpecificBtn btnBuy) {
		this.btnBuy = btnBuy;
	}

	public JLabel getLabImg() {
		return labImg;
	}

	public void setLabImg(JLabel labImg) {
		this.labImg = labImg;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public JLabel getLabBorder() {
		return labBorder;
	}

	public void setLabBorder(JLabel labBorder) {
		this.labBorder = labBorder;
	}

	public AddTeXiaoMouslisten getXiaoMouslisten() {
		return xiaoMouslisten;
	}

	public void setXiaoMouslisten(AddTeXiaoMouslisten xiaoMouslisten) {
		this.xiaoMouslisten = xiaoMouslisten;
	}
}
